require_relative "../Expr"

# Expression for representing parameter lists (for functions)
#
# @author Paul T.
class Calcula::Exprs::ParamsExpr < Calcula::Expr

  # @param params [Array<Calcula::Token>] The tokens should all have type of ID
  def initialize(params)
    @params = params
  end

  # @see Calcula::Expr#to_s
  # @param (see Calcula::Expr#to_s)
  # @return (see Calcula::Expr#to_s)
  def to_s(form: :src)
    case form
    when :src then
      @params.collect { |e| e.text }.join(',')
    when :tree, :ruby then
      "(#{self})"
    else
      nil
    end
  end

  # @see Calcula::Expr#children
  # @param (see Calcula::Expr#children)
  # @return (see Calcula::Expr#children)
  def children
    []
  end
end
